<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css"
          integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <link rel="stylesheet" href="/static/css/dashboard.css">


    <style>

        .table > tbody > tr > td, .table > tbody > tr > th, .table > tfoot > tr > td, .table > tfoot > tr > th, .table > thead > tr > td, .table > thead > tr > th {

            padding: 8px;
            line-height: 1.42857143;
            vertical-align: middle;
            border-top: 1px solid #ddd;
        }

    </style>
</head>


<body>

<nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
                    aria-expanded="false" aria-controls="navbar">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">Project name</a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
            <ul class="nav navbar-nav navbar-right">
                <li><a href="#">Dashboard</a></li>
                <li><a href="#">Settings</a></li>
                <li><a href="#">Profile</a></li>
                <li><a href="#">Help</a></li>
            </ul>
            <form class="navbar-form navbar-right">
                <input type="text" class="form-control" placeholder="Search...">
            </form>
        </div>
    </div>
</nav>

<div class="container-fluid">
    <div class="row">
        <div class="col-sm-3 col-md-2 sidebar">
            <ul class="nav nav-sidebar">
                <li><a href="/publisher_list/">出版社列表 <span class="sr-only">(current)</span></a></li>
                <li class="active"><a href="/book_list/">书籍列表 <span class="sr-only">(current)</span></a></li>

            </ul>

        </div>
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
            <h3 class="sub-header">书籍列表</h3>
            <div class="table-responsive">

                <a class="btn btn-primary btn-sm" href="/book_add/"> 添加 </a>

                <table class="table table-striped">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>ID</th>
                        <th>书名</th>
                        <th>作者</th>
                        <th>出版社</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for book in all_books %}

                        <tr>
                            <td>{{ forloop.counter }}</td>
                            <td>{{ book.pk }}</td>
                            <td>{{ book.title }}</td>
                            <td>
                                {% for author in book.author_set.all %}
                                    {{ author.name }}
                                {% endfor %}


                            </td>
                            <td>{{ book.pub.name }}</td>
                            <td>
                                <a class="btn btn-danger btn-sm" href="/book_del/?pk={{ book.pk }}">删除</a>
                                <a class="btn btn-warning btn-sm" href="/book_edit/?pk={{ book.pk }}">编辑</a>
                            </td>

                        </tr>
                    {% endfor %}


                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>


</body>
</html>